package com.junyi.guava;

import com.google.common.collect.Range;
import com.google.common.collect.RangeMap;
import com.google.common.collect.TreeRangeMap;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

/**
 * 范围 Map
 * @time: 2022/4/7 17:39
 * @version: 1.0
 * @author: junyi Xu
 */
@Slf4j
public class RangeMapMy {

    @Test
    public void test() {
        RangeMap<Integer, String> rangeMap = TreeRangeMap.create();
        rangeMap.put(Range.closedOpen(0,60),"fail");
        rangeMap.put(Range.closed(60,90),"satisfactory");
        rangeMap.put(Range.openClosed(90,100),"excellent");

        log.info("{}", rangeMap.get(59));
        log.info("{}", rangeMap.get(60));
        log.info("{}", rangeMap.get(90));
        log.info("{}", rangeMap.get(91));

        rangeMap.remove(Range.closed(70,80));
        log.info("{}", rangeMap.get(75));
    }
}
